    	 function loginRedirect() {
    	    var url_string = '/Xplore/login.jsp';
    	    window.location = url_string;
    	 }
    	 
    	 function loginRedirect(reason) {
     	    var url_string = '/Xplore/login.jsp?reason='+reason;
     	    window.location = url_string;
     	 }

    	 function loginRedirectForPageTagging(eventType) {
    		    ntptEventTag(eventType);
    		    var url_string = '/Xplore/login.jsp';
    		    window.location = url_string;
    	}
     	
    	 function onSubmitQuery(){
   			this.sortType = $('sortType');
   			this.rowsPerPage = $('rowsPerPage');
   			this.primary_fields = $('primary-search').select('.primary-fields .field-group');
   			this.as_sources = $('as-sources');
   			this.as_content = $('as-content-types');		
   			this.as_topics = $('as-topics');
   			this.as_date_range = $('as-date-range');
   			this.search_interface = $('search-interface');
   			this.srchIntElements = this.search_interface.select('input');
   			
    		var url_string = 'http://10.108.107.221/lab/Searchresult.html?action=search'+
			'&'+this.sortType.id+'='+this.sortType.value+
			'&'+this.rowsPerPage.id+'='+this.rowsPerPage.value;
    		for(var i=0; i<this.srchIntElements.length;i++){
				if(this.srchIntElements[i].checked){
					url_string=url_string+'&searchField='+this.srchIntElements[i].id;
				}
			}
			if(this.primary_fields.length<=0){
				 alert("40");
				return false;
			}		
			
			var field_group, fields, opElement, op, srchTermElement, srchKeyElement, srchKey, pairs,querytext;
			queryText='';
			pairs='';
			
			field_group = this.primary_fields[0];
			fields = field_group.childElements();
			srchTermElement = fields[0].childElements()[1];
			if(srchTermElement && srchTermElement.value!=null&&srchTermElement.value.length>0){
				//alert("51");
				if(!filterQueryElement(srchTermElement)) {
					//alert("54");
					return false;
				}
				//alert("56");
				srchKeyElement = fields[1].childElements()[1];
				srchKey = srchKeyElement.options[srchKeyElement.selectedIndex].value;
				//alert("59");
				if(srchKey == '')
					queryText = '&queryText1='+validateSearchTerms(srchTermElement.value);
				else{
					pairs = '&'+'key1'+'='+validateSearchTerms(srchTermElement.value);
					pairs +='&'+'value1'+'='+srchKey;
				}
			}
			for(var i=1; i<this.primary_fields.length; i++){
				field_group = this.primary_fields[i];
				fields = field_group.childElements();
				srchTermElement = fields[1].childElements()[1];
				if(srchTermElement.value!=null&&srchTermElement.value.length>0){
					if(!filterQueryElement(srchTermElement)) {
						alert("70");
						return false;
					}
					opElement = fields[0].childElements()[1];
					op = opElement.options[opElement.selectedIndex].value;
					srchKeyElement = fields[2].childElements()[1];
					srchKey = srchKeyElement.options[srchKeyElement.selectedIndex].value;
					var paramPair='';
					if(srchKey == ''){
						queryText += '&queryText'+(i+1)+'='+validateSearchTerms(srchTermElement.value);
						queryText += '&queryTextLogic'+(i+1)+'='+op;
					}
					else{
						pairs += '&'+'key'+(i+1)+'='+validateSearchTerms(srchTermElement.value);
						pairs += '&'+'value'+(i+1)+'='+srchKey;
						pairs += '&'+'logic'+(i+1)+'='+op;
					}
				}
			}
			pairs=queryText+pairs;
			url_string=url_string+"&matchBoolean=true";
			if(pairs!=null&&pairs.length>0){
				url_string=url_string+pairs;
			}else{
				alert("You input nothing");// 这块加不加alert都行 alert("Please enter one or more keywords");
				//return false;
			}
			
			var subscribedCheckbox = document.getElementById('subscribed-content');
			if (subscribedCheckbox != null) {
				if (subscribedCheckbox.checked == true) {
					url_string += '&subscribed=true';
				}	
			}
			
			var openAccessCheckbox = document.getElementById('open-access');
			if (openAccessCheckbox != null) {
				if (openAccessCheckbox.checked == true) {
					url_string += '&openAccess=true';
				}	
			}
			var fileCabinetCheckbox = document.getElementById('adv-file-cabinet');
			if (fileCabinetCheckbox != null) {
				if (fileCabinetCheckbox.checked == true) {
					url_string += '&fileCabinet=true';
				}	
			}
			
			var selectedYear = getSelectedYears();
			var selectedValues = getSelectedRefinements(this.as_sources,true)+
							 getSelectedRefinements(this.as_content,true)+
			 				getSelectedRefinements(this.as_topics,false)+
			 				selectedYear+getOtherSearchInfo();
				url_string=url_string+selectedValues;
				//searchGlobalSubmit.disableSubmit();
				window.location=encodeURI(url_string);
				//alert("129");
   			return false;
   	 }

    function validateSearchTerms(searchTerms){
 		if(searchTerms==null){
 			return null;
 		}
 		var splitTerms=searchTerms.split(" ");
 		if(splitTerms==null||splitTerms.length<2){
 			return searchTerms;
 		}
 		var returnTerms = splitTerms[0];
 		for(i=1; i<splitTerms.length;i++){
 			returnTerms = returnTerms+ " "+splitTerms[i];
			//alert(returnTerms);
 		}
 		return returnTerms;
 	}
 	
	function getSelectedRefinements(dimElement, voidAllChecked){
		var selectedRefinementsURL='';
		if(dimElement==null){return selectedRefinementsURL;}
		var refinements = dimElement.select('input');
		if(refinements==null){return selectedRefinementsURL;}
		var checkedCount=0;		
		for(var i=0; i<refinements.length;i++){
			var aRefinement = refinements[i];
			if(aRefinement.checked){
				if(checkedCount)
					selectedRefinementsURL +='-'+aRefinement.value;
				else
				selectedRefinementsURL = '&area='+aRefinement.value;
				checkedCount++;
			}
		}
		if(voidAllChecked&&checkedCount==refinements.length){
			selectedRefinementsURL='';
		}
		return selectedRefinementsURL;
	}  
	
	function getSelectedYears(){
		this.as_date_range = $('as-date-range');
		if(this.as_date_range==null||this.as_date_range.select('input')==null)
			return '';
		var dim_publication_year = $('DIM_PUBLICATION_YEAR');
		var param_add_range = 'time';//$('PARAM_ADD_RANGE').value;
		var selectedYears='';
		var inputElements = this.as_date_range.select('input');
		
		if(inputElements[0].checked){//filter of last update
			return '&'+param_add_range+'='+inputElements[0].value;			
		}else if(inputElements[1].checked){//publication year range
			var yearSelect, yearFrom, yearTo;			
			var yearElements = this.as_date_range.select('select');			
			yearSelect = yearElements[0];
			yearFrom = yearSelect.options[yearSelect.selectedIndex].value;
			yearSelect = yearElements[1];
			yearTo = yearSelect.options[yearSelect.selectedIndex].value;
			
//			selectedYears='&'+param_add_range+'='+selectedYears+'|'+yearFrom+"|"+yearTo;
			selectedYears='&'+param_add_range+'='+yearFrom+"_"+yearTo;
			return selectedYears;
		}else if(inputElements[2].checked){//all the available years
			return '';
		}
		return '';
	}	
	
	function getOtherSearchInfo()
	{
		var otherInfoUrl="";
		//原文语言
		var choice= $('language_of_paper').select('input');
		if(choice!=null)
		{
			for(var i=0;i<choice.length;++i)
			{
				if(choice[i].checked && choice[i].value!="全部"){
					otherInfoUrl+="&"+"paperlanguage="+choice[i].value;
					break;
				}
			}
		}
		
		var select_count=0;
		//影响因子
		choice= $('infectionFactor').select('input');
		if(choice!=null)
		{
			
			var infection='';
			select_count=0;
			for(var i=0;i<choice.length;++i)
			{
				if(choice[i].checked){
					if(select_count){
						infection +="_"+choice[i].value;
					}
					else{
						infection = '&infection='+choice[i].value;
					}
					select_count+=1;
				}
				
			}
			otherInfoUrl+=infection;
		}
		
		//期刊分区
		choice= $('area_of_journal').select('input');
		if(choice!=null)
		{
			var jarea='';
			select_count=0;
			for(var i=0;i<choice.length;++i)
			{
				if(choice[i].checked){
					if(select_count){
						jarea +="_"+choice[i].value;
					}
					else{
						jarea = '&JnalLevel='+choice[i].value;
					}
					select_count+=1;
				}
			}
			otherInfoUrl+=jarea;
		}
		//CCF等级
		choice= $('level_of_conf').select('input');
		if(choice!=null)
		{
			var  clevel='';
			select_count=0;
			for(var i=0;i<choice.length;++i)
			{
				if(choice[i].checked){
					if(select_count){
						clevel +="_"+choice[i].value;
					}
					else{
						clevel = '&CCFLevel='+choice[i].value;
					}
					select_count+=1;
				}
			}
			otherInfoUrl+=clevel;
		}
		
		return otherInfoUrl;
	}
	
	function onSubmitQueryPublicationQuickSearch(){
		this.sortType = $('sortType');
		this.rowsPerPage = $('rowsPerPage');
		this.newsearch = $('newsearch');
		this.param_searchWitin = $('paramSrchWithin');
		var url_string = '/search/searchresult.jsp?action=search'+
		'&'+this.sortType.id+'='+this.sortType.value+
		'&'+this.rowsPerPage.id+'='+this.rowsPerPage.value;
		if(newsearch){
			url_string = url_string +'&newsearch=true';
		}
		this.quickSrchFrm = $('quick-search-form');
		this.input_elements = this.quickSrchFrm.select('[type="text"]');
		this.queryString='';
		for(var i=0; i<this.input_elements.length;i++){		
			var inputElement = this.input_elements[i];
			if(inputElement.value!=null&&inputElement.value.length>0){
				if(!filterQuery(inputElement.id)) return false;
				if(queryString.length<1){
					queryString = this.param_searchWitin.value+'='+'"'+inputElement.name+'"'+':'+inputElement.value;		
				}else{
					queryString = queryString+'&'+this.param_searchWitin.value+'='+'"'+inputElement.name+'"'+':'+inputElement.value;
				}
			}
			if(inputElement.id == 'pqs_doi' && inputElement.value!=null && inputElement.value.length>0)
				break;
			
		}
		if(queryString.length>0){
			url_string=url_string+'&'+queryString;
			//searchGlobalSubmit.disableSubmit();
			window.location = encodeURI(url_string);
		    //location.href=url_string;
			return;
		}else{
			alert("231:Please enter one or more keywords");
		}
		return false;
	}
	var j$ = jQuery.noConflict();
	/**
	 * Changes the value of the advanced-search.jsp help href to the given hrefValue
	 * The function is called from one of the three tabs (Advanced Keyword/Phrases,
	 * Command Search, or Publication Quick Search) with the onClick event. 
	 * @param hrefValue
	 * @return
	 */
	function setHelpHref(hrefid, hrefValue)
	{
		var id = '#'+hrefid;
		j$(id).attr('href', hrefValue);	
	}
	
	j$(function(){
	       j$("#year_from, #year_to").change(function() {
	    	   j$('#radio_range').attr('checked', 'checked');
	       }); 
	});
	function applySpecialCharacterMapping(terms, ignoreBrackets) {
		for (var i = 0; i < SPECIAL_CHARACTERS.length; i++) {
			if(ignoreBrackets && (SPECIAL_CHARACTERS[i] == '(' || SPECIAL_CHARACTERS[i] == ')')) {
				continue;
			}
			var index = terms.indexOf(SPECIAL_CHARACTERS[i]);
			while (index > -1) {
				terms = terms.replace(SPECIAL_CHARACTERS[i], SPECIAL_CHARACTER_REPLACEMENTS[i]);
				index = terms.indexOf(SPECIAL_CHARACTERS[i]);
			}
		}
		return terms;
	}
	function getFilteredTermsExt(terms, ignoreBrackets) {
	    terms = terms.replace(/\*+/, "*").replace(/\s+/, " ");
	    terms = applySpecialCharacterMapping(terms, ignoreBrackets);
	    terms = terms.replace(/^\s+|\s+$/g, "");
	    return terms;
	}

	function getFilteredTerms(terms) {
	    return getFilteredTermsExt(terms, false)
	}

	function authorLink(authorTerm, authorId) {
		var filteredtTerm = getFilteredTerms('"' + authorTerm + '"');
	    var link = '/search/searchresult.jsp?' + searchPropertiesParamSearchWithin + '=' + authorsGetReference + ':' + filteredtTerm;
	    if (authorId && authorId.length > 0)
	    {
	    	var authorIdParam =authorIdReference+ ':' +authorId;
	        link += '&' +searchPropertiesParamSearchWithin + '=' + authorIdParam;
	    }
	    link += '&' + searchPropertiesParamNewSearch + '=true';    
	    return link;
	}
	
